#include <stdio.h>

#include <windows.h>

#include "lib.h"

#include "jokcrdmg.h"
#include "pghand.h"
#include "optplyr.h"

static JokerCardMgr sMgr;

#define SETCARD(i, ndx)		hand.replaceAt(i, ndx)

class TestPGPokerHand : public PGPokerHand
{
	public:
		TestPGPokerHand() : PGPokerHand(&sMgr) { }
		void replaceAt(int32 i, int32 ndx) { cards[i] = mgr->makeCard(ndx); }
};

void
erase()
{
	COORD org;
	CONSOLE_SCREEN_BUFFER_INFO ci;
	DWORD dummy;
	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &ci);
	org.X = org.Y = 0;
	FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE),' ',
		ci.dwSize.X * ci.dwSize.Y, org, &dummy);
}

void
setPos(int x, int y)
{
	COORD pos;

	pos.X = x;
	pos.Y = y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}

void
main()
{
	int32 i,j,k,l,m,n,o;
	TestPGPokerHand hand;
	int32 twocard[2];
	int32 cnt, tenThousand;

	for (i = 0; i < 7; i++)
		hand.add(0x00);

	cnt = tenThousand = 0;

	erase();
	setPos(0, 24);
	printf("i,j,k,l,m,n,o: ");

	for (i = 0; i < 53; i++)
	{
		for (j = i + 1; j < 53; j++)
		{
			for (k = j + 1; k < 53; k++)
			{
				for (l = k + 1; l < 53; l++)
				{
					for (m = l + 1; m < 53; m++)
					{
						for (n = m + 1; n < 53; n++)
						{
							for (o = n + 1; o < 53; o++)
							{
								SETCARD(0, i);
								SETCARD(1, j);
								SETCARD(2, k);
								SETCARD(3, l);
								SETCARD(4, m);
								SETCARD(5, n);
								SETCARD(6, o);

#if 1
								setPos(15, 24);
								printf("%2d,%2d,%2d,%2d,%2d,%2d,%2d",
									i,j,k,l,m,n,o);

								setPos(0, 25);
#endif
								OptimalPlayer::split(&hand, twocard);
	if (++cnt >= 10000)
	{
		++tenThousand;
		setPos(0, 23);
		printf("%9d x 10k\n", tenThousand);
		cnt = 0;
	}
							}
						}
					}
				}
			}
		}
	}

	// deleting the hand deletes the cards
	//
}
